package ferp.core.ai.nn.activation;

/**
 * User: igorgok
 * Date: 12/2/13 3:42 PM
 */
public class HyperbolicTangent implements Activation
{
  // instance
  public static final Activation instance = new HyperbolicTangent();

  @Override
  public double activate(double d)
  {
    return Math.tanh(d);
  }

  @Override
  public double derivative(double d)
  {
    double t = Math.tanh(d);

    return 1 - t * t;
  }

  // singleton
  protected HyperbolicTangent() {}
}
